package com.example.pwj.ffstudy.ui.fragment;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.blankj.utilcode.util.LogUtils;
import com.example.pwj.ffstudy.R;
import com.example.pwj.ffstudy.base.BaseFragment;

import butterknife.BindView;

/**
 * Created by pwj on 2017/8/24.
 */

//使用需要include layout_title
public abstract class ContainerFragment extends BaseFragment{
    @BindView(R.id.toolbar)
    protected Toolbar mToolbar;
    protected ActionBar mActionBar;

    @Override
    protected void init() {
        AppCompatActivity activity = (AppCompatActivity) getActivity();
        activity.setSupportActionBar(mToolbar);
        mActionBar = activity.getSupportActionBar();
        setHasOptionsMenu(true);
        initFm();
    }

    protected abstract void initFm();

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                LogUtils.e("back");
                back();
                break;
        }
        return true;
    }
}
